#include "ScnsLed.c.h"

#if defined(SCNS_LED_ENABLE)&&SCNS_LED_ENABLE==1

#include "ScnsYing.h"
#include "ScnsTm1638.h"
#include "ScnsPcf8574.h"

//GR,SEG
static const uint8 tmMap[15]={0X00,0X01,0X02,0X03,0X04,0X10,0X11,0X12,0X13,0X14,0X20,0X21,0X22,0X23,0X24,};

static const uint8 tmExMap[16]={0X08,0X18,0X28,0X38,0X48,0X58,0X68,0X78,0X09,0X19,0X29,0X39,0X49,0X59,0X69,0X79,};

void scnsBspLedSet(ScnsLedEnum ledN,ScnsLedSwitch status)
{
    if(ledN==SCNS_LED_E3)
        LED_E3_GPIO_Port->BSRR=((status==SCNS_LED_SWITCH_ON))?(LED_E3_Pin):(LED_E3_Pin<<16);
    else if(ledN==SCNS_LED_PCF3)
        scnsPcf8574WriteBit(SCNS_PCF8574_1,3,(status==SCNS_LED_SWITCH_ON)?1:0);
    else if(ledN>=SCNS_LED_D15&&ledN<=SCNS_LED_D14)
        scnsTm1638SetLed(SCNS_TM1638_ON_BOARD,(tmMap[ledN-SCNS_LED_D15]&0XF0)>>4,tmMap[ledN-SCNS_LED_D15]&0X0F,status==SCNS_LED_SWITCH_ON?1:0);
    else if(ledN>=SCNS_LED_STB0_D1&&ledN<=SCNS_LED_STB0_D16)
        scnsTm1638SetLed(SCNS_TM1638_STB0,(tmExMap[ledN-SCNS_LED_STB0_D1]&0XF0)>>4,tmExMap[ledN-SCNS_LED_STB0_D1]&0X0F,status==SCNS_LED_SWITCH_ON?1:0);
    
}

#endif
